
package com.catsic.zcjc.specifiction;

import com.catsic.base.specification.BaseSpec;
import com.catsic.base.specification.QueryWraper;
import com.catsic.zcjc.condition.MarkLabelCondition;
import com.catsic.zcjc.constants.ZcjcConstants;
import com.catsic.zcjc.entity.MarkLabel;

public class MarkLabelSpec extends BaseSpec<MarkLabel> {

	public MarkLabelSpec(MarkLabelCondition condition){
		super(condition);
	}
	

	@Override
	protected void addCondition(QueryWraper<MarkLabel> queryWraper) {
		
		MarkLabelCondition condition = (MarkLabelCondition) getCondition();
		
		Integer type = condition.getType();
		this.addEqualCondition(queryWraper, "type");
		
		if(type==ZcjcConstants.LABEL_TYPE_PRIVATE){
			this.addEqualCondition(queryWraper, "createId");
		}
		
		/**
		 * 自定义排序
		 */
		queryWraper.addOrder(queryWraper.getCb().desc(queryWraper.getRoot().get("label")));
	    
		
	}
}
